package ai.fabu.dataplatform.utils;

import lombok.extern.slf4j.Slf4j;

import javax.validation.constraints.NotBlank;
import javax.xml.bind.DatatypeConverter;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

@Slf4j
public class StringUtil {
    public static String getMD5(@NotBlank String input) throws NoSuchAlgorithmException {
        MessageDigest messageDigest = MessageDigest.getInstance("MD5");
        messageDigest.update(input.getBytes());
        byte[] bytes = messageDigest.digest();
        return DatatypeConverter.printHexBinary(bytes);
    }
}
